springboot下mybatis 您所在的位置:网站首页 spring mybatis配置 springboot下mybatis

springboot下mybatis

2023-03-06 10:40| 来源: 网络整理| 查看: 265

springboot下mybatis-plus开启打印sql日志的配置指南

需要以下三个配置

1:设置mybatisplus包下的日志级别为DEBUG;

logging: level: com: baomidou: mybatisplus: DEBUG

2:设置项目mapper目录(dao包路径)的日志级别为DEBUG;

logging: level: com: xxx: xxx xxx: DEBUG

3:设置mybatis-plus的日志输出方式为slf4j。

mybatis-plus: #mapper-locations: classpath*:/mappings/**/*.xml configuration: log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl

附:关闭打印

在生产环境,不想打印 SQL 日志,可以通过下面的配置关闭。

mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl

对于 application.properties 文件

mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.nologging.NoLoggingImpl

有时候,这个 log-impl 的值是通过外界传入的,通过配置的形式控制 SQL 打印效果,则可以:

mybatis-plus: configuration: log-impl: ${mybatis-plus-log-impl}

${mybatis-plus-log-impl} 不同的值就能实现。

总结

关于springboot下mybatis-plus开启打印sql日志的文章就介绍至此,更多相关mybatis-plus开启打印sql日志内容请搜索编程宝库以前的文章,希望以后支持编程宝库!

下一节:Mybatis中where标签与if标签结合使用详细说明Java编程技术

 前言由于不小心将and或者or写在了语句后面,导致mybatis无法自主判别,这种问题在新上手的同学中很是常见。下面我们探讨一下,在哪些情况下Mybatis无法判断动态S ...



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有